//
//  CodingStrinTool.swift
//  HappyEat
//
//  Created by ctx2016 on 17/1/21.
//  Copyright © 2017年 陌路是我. All rights reserved.
//

import UIKit

private let ShareInstance:CodingStrinTool = CodingStrinTool()

class CodingStrinTool: NSObject {
    class var shareInstance:CodingStrinTool{
        return ShareInstance
    }
}
extension CodingStrinTool{
    public func stringEquto(_ aString:String,_ bString:String)->Bool{
        if aString == bString {
            return true
        }else{
            return false
        }
    }
    public func isRegexPhoneNum(_ phoneNum:String)->Bool {
        if phoneNum.characters.count != 11 {
            return false
        }
        let regexString:String = "^((13[0-9])|(147)|(15[^4,\\D])|(18[0-9])|(17[0-9]))\\d{8}$"
        let regexMobile:NSPredicate = NSPredicate.init(format: "SELF MATCHES %@", regexString)
        if regexMobile.evaluate(with: phoneNum) {
            return true
        }
        else{
            return false
        }
    }
    /*
     base64加密
     */
    public  func base64Encoding(plainString:String)->String
    {
        let plainData = plainString.data(using: String.Encoding.utf8)
        let base64String = plainData!.base64EncodedString(options: .init(rawValue: 0))
        return base64String
    }
 
}
